<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%base_goods_hy}}".
 *
 * @property integer $hy_id
 * @property integer $sp_id
 * @property string $cpgn
 * @property integer $hysl
 * @property integer $qdsl
 * @property string $gg
 * @property double $sczdj
 * @property double $bhsdj
 * @property double $hsdj
 * @property string $yxq
 * @property string $ccrq
 * @property string $fhdz
 * @property string $mjgsxx
 * @property double $zk
 * @property string $lxr
 * @property string $dhhm
 * @property string $fbsj
 * @property integer $status
 * @property integer $statuses
 * @property string $spm
 */
class BaseGoodsHy extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%base_goods_hy}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['sp_id', 'hysl','xj', 'cs', 'qym', 'qdsl', 'status', 'statuses', 'fhdzid','flag'], 'integer'],
            [['cpgn', 'fhdz'], 'string'],
            [['sczdj', 'bhsdj', 'hsdj', 'zk'], 'number'],
            [['gg', 'yxq', 'ccrq', 'mjgsxx', 'lxr', 'dhhm','fbsj'], 'string', 'max' => 25],
            [['spm'], 'string', 'max' => 128]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'hy_id' => '货源id',
            'sp_id' => '商品ID',
            'cpgn' => '产品功能',
            'hysl' => '货源数量',
            'qdsl' => '起订数量',
            'gg' => '规格',
            'sczdj' => '市场指导价',
            'bhsdj' => '不含税单价',
            'hsdj' => '含税单价',
            'yxq' => '有效期',
            'ccrq' => '出厂日期',
            'fhdz' => '发货地址',
            'mjgsxx' => '卖家公司信息',
            'xj' => '包装要求 是否新旧 新1 旧0',
            'cs' => '残损  完好1 残存0 ',
            'qym' => '区域码  有1 无0',
            'zk' => '折扣',
            'lxr' => '联系人',
            'dhhm' => '电话号码',
            'fbsj' => '发布时间',
            'status' => '0未审核，1已审核，-1禁用',
            'statuses' => '0下架，1上架',
            'spm' => '商品名',
            'fhdzid' => '发货地址id',
            'flag' => '1正常2删除',
        ];
    }
    
      public function addGoodshy($data, $uid,$bzq) {     
        foreach ($data as $k=>$v) {             
                $this->$k =$v;          
        }$this->fbsj=(String)time();$this->qy_id = $uid;$this->yxq = $bzq;
         if($this->save()){
             return true;
         }else{
             return false;
         }
  
    }
       public function updateGoodshy($data) {     
        foreach ($data as $k=>$v) {             
                $this->$k =$v;          
        }$this->fbsj=(String)time();
        $this->update();
        //var_dump($this->errors);
    }
}
